//
//  WKHeaderView.m
//  WKMaybell
//
//  Created by 何文虎 on 2018/12/25.
//  Copyright © 2018 何文虎. All rights reserved.
//

#import "WKUserBooksHeaderView.h"

@interface WKUserBooksHeaderView ()
@property(nonatomic,strong)UIImageView *bgimgView;
@property(nonatomic,strong)UIImageView *headerImgView;
@property(nonatomic,strong)UILabel *nameLb;
@property(nonatomic,strong)UILabel *timeLb;
@property(nonatomic,strong)UIButton *careBtn;
@end

@implementation WKUserBooksHeaderView

- (instancetype)initWithFrame:(CGRect)frame{
    if (self == [super initWithFrame:frame]) {
        [self rectUI];
    }
    return self;
}

- (void)rectUI{
    
    self.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.bgimgView];
    [self.bgimgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.with.mas_equalTo(self);
        make.bottom.mas_equalTo(-44);
    }];
    
    [self addSubview:self.headerImgView];
    [self.headerImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(12);
        make.size.mas_equalTo(CGSizeMake(48, 48));
        make.top.mas_equalTo(NavBarHeight+12);
    }];
    
    [self addSubview:self.nameLb];
    [self.nameLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.headerImgView.mas_right).offset(12);
        make.size.mas_equalTo(CGSizeMake(180, 14));
        make.top.mas_equalTo(self.headerImgView.mas_top).offset(9);
    }];
    
    [self addSubview:self.timeLb];
    [self.timeLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.nameLb.mas_bottom).offset(8);
        make.left.mas_equalTo(self.nameLb.mas_left);
        make.right.mas_equalTo(-12);
        make.height.mas_equalTo(12);
    }];
    
    [self addSubview:self.careBtn];
    [self.careBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.headerImgView.mas_top);
        make.right.mas_equalTo(-12);
        make.size.mas_equalTo(CGSizeMake(19, 19));
    }];
    
    
    UILabel *titleLb = [[UILabel alloc]init];
    [self addSubview:titleLb];
    titleLb.textColor = UIColorFromHex(0x3C3C3C);
    titleLb.font = PFSC_MediumFont(15);
    titleLb.text = @"变美过程";
    [titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(-15);
        make.left.mas_equalTo(12);
        make.width.mas_equalTo(150);
        make.height.mas_equalTo(14);
    }];
    
    UIButton *timeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [timeBtn setTitle:@"按热度" forState:UIControlStateNormal];
    [timeBtn setTitleColor:UIColorFromHex(0x979797) forState:UIControlStateNormal];
    timeBtn.titleLabel.font = PFSC_MediumFont(11);
    [timeBtn setImage:ImageNamed(@"triangle_down") forState:UIControlStateNormal];
    timeBtn.frame = CGRectMake(ScreenWidth-10-60, 15, 60, 14);
    [timeBtn layoutButtonWithEdgeInsetsStyle:WHButtonEdgeInsetsStyleRight imageTitleSpace:5];
    [self addSubview:timeBtn];
    [timeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(-15);
        make.right.mas_equalTo(-12);
        make.width.mas_equalTo(150);
        make.height.mas_equalTo(14);
    }];
    
    [self addSubview:[WHFactory addLineWithFrame:CGRectMake(0, 12+20+48+44+NavBarHeight-1, ScreenWidth, 1)]];
    
    _headerImgView.layer.masksToBounds = YES;
    _headerImgView.layer.cornerRadius = 24;
    _headerImgView.contentMode = UIViewContentModeScaleAspectFill;
    
    
    _bgimgView.backgroundColor = BACK_COLOR;
    _careBtn.backgroundColor = BACK_COLOR;
    
    [_headerImgView sd_setImageWithURL:[NSURL URLWithString:@"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1545740224898&di=008e3b12c5b7387fde75efba12d10cdc&imgtype=0&src=http%3A%2F%2Fimg.chuansong.me%2Fmmbiz_jpg%2FmXjFQ4ibKEbzSnL6QGWhMQAeianBDx6EMYicLVz7TRnMb0UFflrZJKiaSWeGR34AHhTibSmKZWAanqnRgIUNL17XtAg%2F0%3Fwx_fmt%3Djpeg"]];
    _nameLb.text = @"一直小路飞";
    _timeLb.text = @"2018年09月12日j创建 | 共12篇日记";
    
    _careBtn.backgroundColor = [UIColor greenColor];
    
}

- (UIImageView*)bgimgView{
    if (!_bgimgView) {
        _bgimgView = [[UIImageView alloc]init];
    }
    return _bgimgView;
}

- (UIImageView*)headerImgView{
    if (!_headerImgView) {
        _headerImgView = [[UIImageView alloc]init];
    }
    return _headerImgView;
}

- (UILabel*)nameLb{
    if (!_nameLb) {
        _nameLb = [[UILabel alloc]init];
        _nameLb.textColor = [UIColor whiteColor];
        _nameLb.font = PFSC_SemiboldFont(15);
    }
    return _nameLb;
}

- (UILabel*)timeLb{
    if (!_timeLb) {
        _timeLb = [[UILabel alloc]init];
        _timeLb.textColor = [UIColor whiteColor];
        _timeLb.font = PFSC_MediumFont(11);
    }
    return _timeLb;
}

- (UIButton*)careBtn{
    if (!_careBtn) {
        _careBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    }
    return _careBtn;
}

@end
